﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

using ZoneFiveSoftware.Common.Data;
using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Data.Measurement;

using ZoneFiveSoftware.Common.Visuals;
using ZoneFiveSoftware.Common.Visuals.Fitness;

namespace PolarImport.DeviceImporter
{
    class PolarFSeries : IFitnessDevice 
    {
        /// <summary>
        /// Constructor of the FitnessDevice. Set GUID, image, name and connection information.
        /// </summary>
        public PolarFSeries(Settings.PolarDevice Device)
        {
            this.id = Device.GUID;
            this.device = Device;
            this.name = "Polar " + Device.Modells; ;
            System.Resources.ResourceManager resourceManager = Properties.Resources.ResourceManager;
            this.image = (System.Drawing.Image)resourceManager.GetObject("Img_Polar_" + Device.Monitor.ToString());

        } 
        
        #region IFitnessDevice Member

        public string Configure(string configurationInfo)
        {
            DeviceConfiguration prompt = new DeviceConfiguration(device);
            DeviceConfigurationInfo info = DeviceConfigurationInfo.Parse(configurationInfo);
            prompt.ConfigInfo = info;
            if (prompt.ShowDialog() == DialogResult.OK)
            {
                return prompt.ConfigInfo.ToString();
            }
            return null;

        }

        public string ConfiguredDescription(string configurationInfo)
        {
            if (configurationInfo == null)
            {
                return this.Name;
            }
            DeviceConfigurationInfo info = DeviceConfigurationInfo.Parse(configurationInfo);
            return this.Name + Environment.NewLine + info.DeviceName + " : "
                                                   + info.PolarDevice.ToString() + " : "
                                                   + info.UploadConnection.ToString();
        }

        #endregion

        #region IDataImporter Member

        public Guid Id
        {
            get { return id; }
        }

        public System.Drawing.Image Image
        {
            get { return image; }
        }

        public bool Import(string configurationInfo, IJobMonitor monitor, IImportResults importResults)
        {
            return true;
        }

        public string Name
        {
            get { return name; }
        }

        #endregion

        #region Private members

        /// <summary>The unique GUID of this FitnessDevice</summary>
        private Guid id;

        /// <summary>The image to represent this FitnessDevice</summary>
        private System.Drawing.Image image;

        /// <summary>The name of this FitnessDevice</summary>
        private string name;

        private Settings.PolarDevice device;

        #endregion
    }
}
